<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
</head>
<style type="text/css">
.priceSize input {
	display: inline-block;
	width: 20% !important;
	float: left !important;
}
</style>
<form class="mui-input-group">
	<div class="mui-input-row">
		<label>名称:</label> <input type="text" class="layui-input Name"
			id="name" name="name" value="${manageCaseType.name }"
			placeholder="名称"> <input type="hidden" name=typeId
			value="${manageCaseType.typeId }"> <span class="must">*</span>
	</div>
	<div class="mui-input-row">
		<label>计费方式:</label> <select name="payType" class="selectPayType"
			id="demo">
			<option value="0">免费</option>
			<option value="1" selected="selected">计时</option>
			<option value="2">计次</option>
		</select>
	</div>
	<div class="mui-input-row">
		<label>收费时间:</label> <select name="payTime">
			<option value="1" selected="selected">使用后</option>
			<option value="2">使用前</option>
		</select>
	</div>
	<div class="mui-input-row 1 2">
		<label>价格:</label> <input type="number" min="0.0" step="0.1"
			class="layui-input 12 price" value="${manageCaseType.price}"
			name="price" placeholder="请输入价格">
	</div>
	<div class="mui-input-row 1 2 priceSize">
		<label>价格<span style="font-size: 12px;">(大中小):</span></label> <input
			type="number" min="0.0" step="0.1" class="layui-input price-1"
			value="${priceSize[0]}" name="priceSize" placeholder="大"> <input
			type="number" min="0.0" step="0.1" class="layui-input price-2"
			value="${priceSize[1]}" name="priceSize" placeholder="中"> <input
				type="number" min="0.0" step="0.1" class="layui-input price-3"
				value="${priceSize[2]}" name="priceSize" placeholder="小">
	</div>
	<div class="mui-input-row 1 ">
		<label>计时单位:</label> <input type="number" min="0.0" step="0.1"
			class="layui-input userTime" value="${manageCaseType.userTime}"
			name="userTime" placeholder="此价格使用的时间（计时）">
	</div>
	<div class="mui-input-row">
		<label>公司:</label> <select class="comp" name="compId">
			<option value="">--请选择公司--</option>
			<c:forEach items="${compList}" var="list">
				<option value="${list.compId }">${list.compName}</option>
			</c:forEach>
		</select> <span class="must">*</span>
	</div>
	<div class="mui-button-row">
		<a type="button" class="mui-btn mui-btn-primary submit">提交</a>
	</div>
</form>
<script type="text/javascript">
		mui('#offCanvasContentScroll').scroll().scrollTo(0,0);
		
		$(".mui-title").html("添加计费类型");
		//计费方式
		selectPayType();
		
		$('.selectPayType').on('change',function(){
			selectPayType();
		});
		
		function selectPayType(){
			//判断是否选取prompt属性，无返回值；
	        var param = $(".selectPayType").find('option:selected').val();
	        if(param==0){
				$(".1").hide();
			}else if(param==1){
				$(".1").show();
			}else{
				$(".1").hide();
				$(".2").show();
			}
		}
		
	   
	   $(".submit").on("touchstart",function(){
		   var param = $("form").serialize();

		    let name = $(".Name").val();
	    	let compId = $(".comp").val();
	    	
	    	if(name !== "" && compId !== ""){
				$.post("/caseType/addCaseTyep",param,function(res){
					
					if(res.success){
						mui.toast("添加成功");
						history.back();
			    	}else{
			    		mui.toast(res.message);
			    	}
					
				})
	    	}else{
	    		mui.toast("带 "+'<span style="color:red;">*</span> 为必填项');
	    	}
	   })
	   
	</script>
</html>